<template>
	<el-dialog :title="titleMap[mode]" v-model="visible" width="70%" destroy-on-close @closed="$emit('closed')" :close-on-click-modal="false" align-center>
        <el-container>
			<el-header>
                <div class="left-panel">
                    <el-button type="primary" @click="back">确 定</el-button>
                </div>
				<div class="right-panel">
					<div class="right-panel-search">
						<el-input v-model="search.end_price" placeholder="检验项目编号/名称" clearable></el-input>
						<el-button type="primary" icon="el-icon-search" @click="upsearch"></el-button>
						<el-button type="info" @click="refresh">重置</el-button>
					</div>
				</div>
			</el-header>
			<el-main class="nopadding">
				<scTable ref="table" :apiObj="apiObj" row-key="id" @select-all="selectAll" @selection-change="selectionChange" stripe remoteSort remoteFilter border height="460">
					<el-table-column type="selection" width="50" reserve-selection align="center"></el-table-column>
					<el-table-column label="单据编号" prop="check_code" width="120" align="center"></el-table-column>
					<el-table-column label="单据日期" prop="check_date" align="center" width="120"></el-table-column>
					<el-table-column label="物料编码" prop="goods_code" align="center" width="120"></el-table-column>
					<el-table-column label="物料名称" prop="goods_name" align="center" width="120"></el-table-column>
					<el-table-column label="物料规格" prop="goods_spec" align="center" width="120"></el-table-column>
					<el-table-column label="工序代码" prop="work_code" align="center" width="120"></el-table-column>
					<el-table-column label="工序名称" prop="work_name" align="center" width="120"></el-table-column>
					<el-table-column label="请检数量" prop="faskqty" align="center" width="120"></el-table-column>
					<el-table-column label="合格数量" prop="fcomqty" align="center" width="120"></el-table-column>
					<el-table-column label="不合格数量" prop="fnoqty" align="center" width="120"></el-table-column>
					<el-table-column label="请检人" prop="faskstuff_name" align="center" width="120"></el-table-column>
					<el-table-column label="检验员" prop="finspectorname" align="center" width="120"></el-table-column>
					<el-table-column label="工序汇报单号" prop="foptbillno" align="center" width="120"></el-table-column>
					<el-table-column label="检验说明" prop="fdocument" align="center" width="120"></el-table-column>
					<el-table-column label="检验方案代码" prop="quality_code" align="center" width="120"></el-table-column>
					<el-table-column label="检验方案名称" prop="quality_name" align="center" width="120"></el-table-column>
				</scTable>
			</el-main>
		</el-container>
		<template #footer>
			<el-button @click="visible = false">取 消</el-button>
			<el-button v-if="mode != 'show'" type="primary" :loading="isSaveing" @click="back">确 定</el-button>
		</template>
	</el-dialog>
</template>

<script>
export default {
    props:{
        query: { type: Object, default: () => ({}) },
    },
	emits: ['success', 'closed'],
	data() {
		return {
			mode: "add",
			titleMap: {
				add: '选择设备',
				edit: '选择请检单',
			},
			visible: false,
			isSaveing: false,
            apiObj: this.$API.production.checkorder.list,
            selection:[],
            search: {
				keywords: null,
			},
		}
	},
	mounted() {
	},
	methods: {
		//显示
		open(mode = 'add') {
			this.mode = mode;
			this.visible = true;
			return this
		},
        submit(){
            this.visible = false
        },
        //搜索
		upsearch() {
			this.$refs.table.upData(this.search)
		},
        selectAll() {
			this.$message.error("只能单选！")
			this.$refs.table.clearSelection()
		},
        selectionChange(selection) {
			if(selection.length > 1){
				const del_row = selection.shift()
				this.$refs.table.toggleRowSelection(del_row,false) //设置这一行取消选中
			}
			this.selection = selection;
		},
        back(){
            this.$emit('success', this.selection)
            this.visible = false;
        },
	}
}
</script>

<style></style>
